import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmergencyVO, EmergencyForm, EmergencyQuery } from '@/api/nursing/emergency/types';

/**
 * 查询紧急需求列表
 * @param query
 * @returns {*}
 */

export const listEmergency = (query?: EmergencyQuery): AxiosPromise<EmergencyVO[]> => {
  return request({
    url: '/nursing/emergency/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询紧急需求详细
 * @param id
 */
export const getEmergency = (id: string | number): AxiosPromise<EmergencyVO> => {
  return request({
    url: '/nursing/emergency/' + id,
    method: 'get'
  });
};

/**
 * 新增紧急需求
 * @param data
 */
export const addEmergency = (data: EmergencyForm) => {
  return request({
    url: '/nursing/emergency',
    method: 'post',
    data: data
  });
};

/**
 * 修改紧急需求
 * @param data
 */
export const updateEmergency = (data: EmergencyForm) => {
  return request({
    url: '/nursing/emergency',
    method: 'put',
    data: data
  });
};

/**
 * 删除紧急需求
 * @param id
 */
export const delEmergency = (id: string | number | Array<string | number>) => {
  return request({
    url: '/nursing/emergency/' + id,
    method: 'delete'
  });
};
